<?php
class QLogSystem
{	
	static $_table = 'log_system';
	
	static function getByDate($p_Date)
	{
		$strQuery	=	'SELECT * FROM `log_system` WHERE `created_at`="'.$p_Date . '"';
		$db 		=	Zend_Registry::get('db');
		$arrData 	=	$db->fetchAll($strQuery);
		$db->closeConnection();
		return $arrData;
	}	
	
	public static function insert($p_arrParams)
	{
		$db	= Zend_Registry::get('db');
		$resultValue =$db->insert(self::$_table , $p_arrParams);
		$db->closeConnection();
		return $resultValue;
	}
	
	public static function update($p_arrParams)
	{
		$db	= Zend_Registry::get('db');
		$resultValue = $db->update(self::$_table, $p_arrParams, "id=" . "'" .$p_arrParams["id"] . "'");
		$db->closeConnection();
		return $resultValue;
	}
	
	static function getGenerateForecastsLog($strCountry)
	{
		$strQuery	=	'SELECT * FROM `log_system` WHERE `name`="Generate forecats"
						 and country ="' . $strCountry .'" Order by created_at DESC limit 0, 1;';
		$db 		=	Zend_Registry::get('db');
		$arrData 	=	$db->fetchAll($strQuery);
		$db->closeConnection();
		return $arrData;
	}	
}
?>